package com.note.back.mapper;

import com.note.back.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    //根据用户名查询用户
    @Select("select * from user where account=#{account}")
    User findByAccount(String account);
    //根据电话号码查询用户
    @Select("select * from user where email=#{email}")
    User findByUserEmail(String email);
    //添加
    @Insert("insert into user(account,password,salt,username,email)" +
            " values(#{account},#{pwdAfterHash},#{salt},#{account},#{email})")
    void add(String account, String pwdAfterHash, String salt, String email);

    @Update("update user set username=#{username} where id=#{id}")
    void update(User user);

    @Update("update user set password=#{md5String} where id=#{id}")
    void updatePwd(String md5String, Integer id);

    @Update("update user set password=#{pwdAfterHash} where id=#{id}")
    void forgotPassword(int id, String pwdAfterHash);
}
